<%@page import="com.hamizhong.iflowers.utils.MyColumnIndicator"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@include file="../../common/common_admin.jsp" %>
<title>促销管理</title>
</head>

<script type="text/javascript">
$(function() {
	initItemList(1);
});
//初始化数据列表
function initItemList(pageNum) {
	var isBargin = $('#isBargin').val();
	$.ajax({
		url: '<%=request.getContextPath() %>/admin/ajaxQueryGoodsByIsBargin.action',
		data: {
			'pageNum': pageNum,
			'isBargin': isBargin
		},
		type: 'post',
		dataType: 'json',
		async: false,
		success: ajaxQueryGoods_Callback
	});
	function ajaxQueryGoods_Callback(res) {
		var rs = res.result;
		if(rs == 0) {
			var data = res.data;
			var totalCnt = res.totalCnt;
			var totalPageCnt = res.totalPageCnt;
			var pageNum = res.pageNum;
			var itemListHtmlStr = '';
			if(data.length > 0) {
				/*列表*/
				itemListHtmlStr += '<thead>'+
								'<tr>'+
									'<th width="50">商品ID</th>'+
									'<th width="50">展示图</th>'+
									'<th width="200">商品名称</th>'+
									'<th width="50">价格</th>'+
									'<th width="80">是否特价</th>'+
									'<th width="80">特价</th>'+
									'<th width="200">花语</th>'+
									'<th width="50">支数</th>'+
									'<th width="50">排序号</th>'+
									'<th width="100">操作</th>';
								'</tr>'+
							'</thead>';
				for(var i=0;i<data.length;i++) {
					itemListHtmlStr += 
								'<tr>'+
									'<td>'+
										data[i].goodsId+
									'</td>'+
									'<td>'+
										'<div style="align: left;width: 50px;height: 50px;">'+
											'<img alt="" src="'<%=request.getContextPath() %>+'/'+data[i].goodsPictureS+'" width="46px" height="46px" style="margin: 2px;">'+
										'</div>'+
									'</td>'+
									'<td>'+
										data[i].goodsName+
									'</td>'+
									'<td>'+
										data[i].goodsPrice+
									'</td>'+
									'<td>'+
										data[i].isBarginStr+
									'</td>'+
									'<td>'+
										data[i].barginPrice+
									'</td>'+
									'<td>'+
										data[i].flowerFloridName+
									'</td>'+
									'<td>'+
										data[i].flowerCountName+
									'</td>'+
									'<td>'+
										data[i].sortId+
									'</td>'+
									'<td>'+
										'<a href="javascript: void(0)" onclick="updateItemBarginState(\''+data[i].goodsId+'\')">修改促销状态</a>&nbsp;&nbsp;'+
									'</td>'+
								'</tr>';
				}
			}else {
				itemListHtmlStr += '<font color="red">当前类别暂无数据项，请添加！</font>';
			}
			$('#itemListTable').html(itemListHtmlStr);
			
			/*分页*/
			var pagingHtmlStr = queryPagingModule(pageNum,totalPageCnt,totalCnt);
			$('#pagingDiv').html(pagingHtmlStr);
		}else {
			alert("初始化数据失败！");
		}
	}
}
</script>

<body>
	<div class="displayPageHeader">当前位置：产商管理 >> 商品管理</div>
	<div class="pageDiv">
		<div class="pageHeadDiv">商品搜索</font></div>
		<div class="infoDiv">
			<form id="itemForm" action="#none" method="post">
				<table>
					<tr>
						<td>
							<td>&nbsp;&nbsp;促销状态&nbsp;&nbsp;</td>
						</td>
						<td>
							<select id="isBargin" onchange="initItemList(1)" style="width: 150px;">
								<option selected="selected" value="<%=MyColumnIndicator.G_BARGIN_ST_B1 %>"><%=MyColumnIndicator.G_BARGIN_ST_STR_B1 %></option>
								<option value="<%=MyColumnIndicator.G_BARGIN_ST_A0 %>"><%=MyColumnIndicator.G_BARGIN_ST_STR_A0 %></option>
							</select>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
	<div class="pageDiv">
		<div class="pageHeadDiv">商品列表</div>
		<div class="infoDiv">
			<div class="itemListDiv">
				<table border="1px" id="itemListTable">
					
				</table>
			</div>
			<div class="margin_5"></div>
			<div id="pagingDiv" style="border: 1px solid #CCC;width: 100%;height: 25px;line-height: 25px;text-align: left;">
				
			</div>
		</div>
	</div>
	<div class="margin_50"></div>
</body>

<script type="text/javascript">

	//更新数据操作
	function updateItemBarginState(goodsId) {
		//$('#goodsId').val(goodsId);
		alertGoodsBarginStateUpdateWindow(goodsId);
	}
	
	function alertGoodsBarginStateUpdateWindow(goodsId) {
		//vReturnValue = window.showModelessDialog(sURL,[vArguments],[sFeatures]);
		//vArguments:可选参数，类型：变体。用来向对话框传递参数。传递的参数类型不限，包括数组等
		//var obj = new Object(); obj.name="testname";
		//对话框通过window.dialogArguments来取得传递进来的参数。
	    var retValue;
		var pageURL = '<%=request.getContextPath() %>/admin/goodsBarginStateUpdate.action?goodsId='+goodsId+'&random='+Math.random();
		var dialogWidth = 800;
		var dialogHeight = 500;
		var dialogTop = (screen.height - dialogHeight)/2;
		var dialogLeft = (screen.width - dialogWidth)/2;
		var params = 'dialogTop:'+dialogTop+'px;dialogLeft:'+dialogLeft+';dialogWidth:'+dialogWidth+'px;dialogHeight:'+dialogHeight+'px;help:no;unadorned:no;resizable:no;status:no;';
		retValue = window.showModalDialog(pageURL,window,params);
	    //弹出窗口通过：window.returnValue="xxx"; 返回值。也可以是对象
	    //alert(retValue);
	}

</script>

</html>